Hi, I'm writing an DXL script to convert data from DOORs to reStructuredText. How can I parse a table inside "Object Text"? Is there any possibility to use functions like table(o), cell(o), row(o) on them? I have a loop which looks something like this:
string s = richTextWithOle(o."Object Text")
RichTextParagraph rp = null
RichText rt = null
for rp in s do
{
for rt in rp do
{
//I want it to check if it has table inside here
}
}
I know there is possibility in parsing richText manually to get \cell tag etc, but replacing in DXL looks really tedious. The second question is: How can I recognize if OLE Object is file or picture. I want it to display this Object if it's a picture and place a link if it's not.
i=1
if (rt.isOle)
{
EmbeddedOleObject ole = rt.getEmbeddedOle
string filename = o."Absolute Number" "-ole-" i ".png"
errmess = exportPicture(ole, baseFileName"" filename, formatPNG)
buffer+= "\n.. image::" filename
if (!null errmess)
{
print "ERROR: " errmess "\n"
}
i++
}
This prints everything like a picture. If Object is a file it places it's icon. Best regards, Ćukasz Morishiri - Thu Apr 02 01:34:25 EDT 2015 |
Re: DOORS->rST. Parsing tables inside "Object Text", Recognizing OLE Object type Since the DOORS API does not support parsing RTF Tables (inside Object Text) you need to resort to parsing the richtext manually. Funny. I need to do the exact thing until next week. Good to see, that other people have the same problems. The second question is harder. The problem is, that you cannot differentiate between a symbol and a picture of an OLE. OLEs consist of a picture part and a data part. For the picture part you can put anything - only by convention the Windows API uses the Icon of the application associated with the the OLE on the computer that created the OLE. On the computer reading the OLE the application might not even be installed. You can therefore put ANY picture inside the OLE. So to put this short: The information if the OLE has been created as a symbol or a picture does not seem to be available, you could check for the picture size. Maybe this helps, regards, Mathias |
Re: DOORS->rST. Parsing tables inside "Object Text", Recognizing OLE Object type It helped, at least I'm sure now what I have to do. Btw. I compared picture width and height to check if it's icon. If it is I want to place a link to this object, but DOORs link from o."URL Object (DXL)" is not working as I want it to work (Web browser cannot open DOORs). Any ideas how to place the right link? Taking an occassion I will ask one more question. I want to change every occurrence of index_[numbers] to index_[numbers]_ (to make a link). I have some code, but it only prints "Found ..." but does not replace. Replace function takes (source, whatToFind, WhatToPasteInstead) arguments.
string s = richtextWithOle rt
string strgx = "index_[0-9]+"
Regexp rgx = regexp2(strgx)
if(rgx(s))
{
print "Found " s[match 0] "\n"
replace(s, s[match 0], s[match 0] "_")
}
Any ideas?
Thanks for your help :) |
Re: DOORS->rST. Parsing tables inside "Object Text", Recognizing OLE Object type Morishiri - Thu Apr 02 05:41:48 EDT 2015 It helped, at least I'm sure now what I have to do. Btw. I compared picture width and height to check if it's icon. If it is I want to place a link to this object, but DOORs link from o."URL Object (DXL)" is not working as I want it to work (Web browser cannot open DOORs). Any ideas how to place the right link? Taking an occassion I will ask one more question. I want to change every occurrence of index_[numbers] to index_[numbers]_ (to make a link). I have some code, but it only prints "Found ..." but does not replace. Replace function takes (source, whatToFind, WhatToPasteInstead) arguments.
string s = richtextWithOle rt
string strgx = "index_[0-9]+"
Regexp rgx = regexp2(strgx)
if(rgx(s))
{
print "Found " s[match 0] "\n"
replace(s, s[match 0], s[match 0] "_")
}
Any ideas?
Thanks for your help :) Normally for a regexp replace you would build up a destination buffer like so (only pseudo code, not syntax tested). Hope it gives you the idea ... Regards, Mathias
Regexp re = regexp ...
Buffer buf = ...
int pos = 0;
int iLen = length buf;
Buffer bufOut = create();
while (search(buf, re, pos) && pos < iLen) {
int iStart = pos + start 0
int iEnd = pos + end 0
if (pos != iStart) {
// need to add the characters before the match
combine(bufOut, buf, pos, iStart-1)
}
bufOut += ... // add the replacement for the match
pos = iEnd + 1
}
if (pos < iEnd-1) combine(bufOut, buf, pos); // Add the rest after the last match
|
Re: DOORS->rST. Parsing tables inside "Object Text", Recognizing OLE Object type Mathias Mamsch - Tue Apr 07 14:06:05 EDT 2015 Normally for a regexp replace you would build up a destination buffer like so (only pseudo code, not syntax tested). Hope it gives you the idea ... Regards, Mathias
Regexp re = regexp ...
Buffer buf = ...
int pos = 0;
int iLen = length buf;
Buffer bufOut = create();
while (search(buf, re, pos) && pos < iLen) {
int iStart = pos + start 0
int iEnd = pos + end 0
if (pos != iStart) {
// need to add the characters before the match
combine(bufOut, buf, pos, iStart-1)
}
bufOut += ... // add the replacement for the match
pos = iEnd + 1
}
if (pos < iEnd-1) combine(bufOut, buf, pos); // Add the rest after the last match
Thank you! After some changes it works as I wanted. If you will find the answer for OLE Object linking please let me know. I want to download it and then post a link. Problem is in downloading. I found only exportPicture function which accept only PNG format as output.
Tyvm once again :) |